tm.tm_mon -= 1;
tm.tm_year -= 1900;
tm.tm_isdst = 1;
- wpt_tmp->creation_time = mktime(&tm);
-#if 0
- /* mktime assumes local time, and Z is gmtime */
- /* localtime will initialize timezone and daylight */
- /* 12/31/02 - RJL - unfortunately, this fix relies
- * on non-ANSI extensions, so I've turned this off
- * and reverted to the old way.
- */
- localtime( &wpt_tmp->creation_time );
- wpt_tmp->creation_time -= timezone - (daylight?3600:0);
-#else
- wpt_tmp->creation_time = mktime(&tm);
-#endif
+ wpt_tmp->creation_time = mktime(&tm) + get_tz_offset();
}
if (in_wpt && in_gs_type && !in_gs_log) {
wpt_tmp->gc_data.type = gs_mktype(cdatastr);
}
fprintf(file, "%c%f\t", d, fabs(c->degrees));
}
+
void
fatal(const char *fmt, ...)
{
return (signed int)(d+0.5);
}
}
+
+/*
+ * Return a time_t suitable for adding to a time_t that is in GMT to
+ * make it a local time.
+ */
+signed int
+get_tz_offset(void)
+{
+ time_t now = time(0);
+ time_t later = mktime(gmtime(&now));
+
+ if (later == -1) {
+ return 0;
+ } else {
+ return (signed int) difftime(now, later);
+ }
+}